package com.rbac.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rbac.pojo.User;
import lombok.Data;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Insert("insert into role_user (role_id, user_id) values (#{roleId}, #{userId})")
    Integer addRoleUser(@Param("userId") Integer userId,@Param("roleId")  Integer roleId);

//    @Update("update role_user set ")
//    Integer modifyRoleUser(Integer userId, Integer roleId);

    @Select("select role_id from role_user where user_id = #{userId}")
    List<String> queryRoleUserByUserId(Integer userId);

    @Delete("delete from role_user where user_id = #{userId}")
    Integer removeRoleUser(Integer userId);

    @Select("select role_name from role where role_id in (select role_id from role_user where user_id = #{userId})")
    List<String> queryRoleNameListByUserId(Integer userId);
}
